(function(global, $) {
  global.wUtils = $.wUtils = {
    getData : function(data) {
      if (data.resultCode == 1) {
        return data.data
      }

      return undefined;
    }

    , getListData : function() {
      var data = null;
      var key = "list";
      var args = arguments;
      if (args.length > 0) {
        data = $.wUtils.getData(args[0]);
      }
      if (args.length > 1) {
        key = args[1]
      }

      if (data && data[key] && data[key].length) {
        return data[key];
      }

      return undefined;
    }

    , getJson : function() {
      var url = undefined;
      var options = undefined;

      var defaultOptions = {
          data : null
          , type : "GET"
          , dataType : "json"
          , success : null
          , error : null
        };

      if (arguments.length) {
        var arg = arguments[0];
        if (typeof arg === 'string') {
          url = arg;
        } else if (typeof arg === 'object' && arg.constructor === {}.constructor) {

          if (arg.url) {
            url = arg.url;
            delete arg.url;
          }

          options = $.extend({}, defaultOptions, arg);
        }
      }
      if (arguments.length > 1) {
        if (typeof arguments[1] === 'object' && arguments[1].constructor === {}.constructor) {
          options = $.extend(true, defaultOptions, arguments[1]);
        }
      }

      if (url && options) {
        $.ajax(url, options);
      }
    }

    , reload : function() {
      window.location.reload();
    }

    , navigate : function(url) {
      window.location.href = url;
    }

    , getQuery : function() {
      var url = window.location.href;
      var start = url.indexOf("?");
      if (start > -1) {
        var queryStr = url.substring(start + 1);
        var nameValues = queryStr.split("&");
        if (nameValues && nameValues.length) {
          var query = {};
          for (var index in nameValues) {
            var nameValue = nameValues[index];
            var array = nameValue.split("=");
            query[array[0]] = array[1];
          }

          return query;
        }
      }
      return undefined;
    }
  }
})(this, jQuery);